package hc.bre.clas

import hc.bre.clas.range.RangeOption
import hc.bre.cmn.IDetailList
import hc.bre.cmn.ListOption
import hc.bre.cmn.RuleDefinition
import hc.bre.cmn.struct.DataStruct
import hc.bre.cmn.struct.DataStructItem
import java.lang.reflect.ParameterizedType

@groovy.transform.CompileStatic
@groovy.transform.ToString(includeNames=true, includePackage = false)
class ClasRuleDefinition <T extends ListOption> extends RuleDefinition implements IDetailList<T>{
	List<T> list;

	@Override
	public ClasRuleDefinition load(Map map) {
		super.load(map);
		list = hc.Util.loadList(map['list'], realClass())
		return this;
	}

	Class<T> realClass() {
		ParameterizedType pt = (ParameterizedType) this.getClass().getGenericSuperclass();
		return (Class<T>) pt.getActualTypeArguments()[0];
	}
}
